﻿// https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/
// 104. 二叉树的最大深度

#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <limits.h>

using namespace std;

// struct ListNode {
//     int val;
//     ListNode *next;
//     ListNode() : val(0), next(nullptr) {}
//     ListNode(int x) : val(x), next(nullptr) {}
//     ListNode(int x, ListNode *next) : val(x), next(next) {}
// };

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode() : val(0), left(nullptr), right(nullptr) {}
    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};

class Solution {
public:
    int maxDepth(TreeNode *root) {
        if (root == nullptr)
            return 0;
        int max_depth = 0;
        FindDepth(root, 0, max_depth);
        return max_depth;
    }

    void FindDepth(TreeNode *root, int depth, int &max_depth) {
        if (root == nullptr)
            return;
        depth++;
        if (depth > max_depth)
            max_depth = depth;
        FindDepth(root->left, depth, max_depth);
        FindDepth(root->right, depth, max_depth);
        return;
    }
};

int main() {
    Solution obj = Solution();
}